<?php

require '../config.php';
require '../lib/request_api.php';
require '../lib/json_fix.php'; 
require '../lib/subdownloader_cli.class.php';


$subdownloader_cli = new SubDownloaderCli(SUBDOWNLOADER_BIN);

try {
	$subdownloader_cli->rename_subs = request_param("rename_subs",false);
	$subdownloader_cli->path_to_scan = request_required_param("path_to_scan");
	$subdownloader_cli->language = request_required_param("language");
	
	echo "Executing ".$subdownloader_cli->build_cmd(),"<br/>";
	
	$result = $subdownloader_cli->exec();
	if($result) {
		echo implode("<br/>",$result);	
	} else {
		echo "ERROR: Oops... Bash return nothing";
	}
	
} catch (Exception $e) {
	echo "ERROR: ".$e->getMessage();
}



 



?>